﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Simple.Master" AutoEventWireup="true" CodeBehind="QuanLyGia.aspx.cs" Inherits="BieuDoGiaVang.QuanLyGia" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <h1>Quản lý giá vàng SJC</h1>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="Ngay" 
        DataSourceID="ObjectDataSource1" DefaultMode="Insert" 
    oniteminserted="FormView1_ItemInserted">
        <EditItemTemplate>
            Ngay:
            <asp:Label ID="NgayLabel1" runat="server" Text='<%# Eval("Ngay") %>' />
            <br />
            GiaMua:
            <asp:TextBox ID="GiaMuaTextBox" runat="server" Text='<%# Bind("GiaMua") %>' />
            <br />
            GiaBan:
            <asp:TextBox ID="GiaBanTextBox" runat="server" Text='<%# Bind("GiaBan") %>' />
            <br />
            NgayTao:
            <asp:TextBox ID="NgayTaoTextBox" runat="server" Text='<%# Bind("NgayTao") %>' />
            <br />
            NgayCapNhat:
            <asp:TextBox ID="NgayCapNhatTextBox" runat="server" 
                Text='<%# Bind("NgayCapNhat") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            Ngày:
            <asp:TextBox ID="NgayTextBox" runat="server" Text='<%# DateTime.Now.ToShortDateString() %>' ReadOnly="true"/>
            <br />
            Giá mua:
            <asp:TextBox ID="GiaMuaTextBox" runat="server" Text='<%# Bind("GiaMua") %>' />
            <br />
            Giá bán:
            <asp:TextBox ID="GiaBanTextBox" runat="server" Text='<%# Bind("GiaBan") %>' />
            <br />                      
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            Ngay:
            <asp:Label ID="NgayLabel" runat="server" Text='<%# Eval("Ngay") %>' />
            <br />
            GiaMua:
            <asp:Label ID="GiaMuaLabel" runat="server" Text='<%# Bind("GiaMua") %>' />
            <br />
            GiaBan:
            <asp:Label ID="GiaBanLabel" runat="server" Text='<%# Bind("GiaBan") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />
        &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
        </ItemTemplate>
    </asp:FormView>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="Ngay" DataSourceID="ObjectDataSource1" 
    onrowdeleted="GridView1_RowDeleted" Width="100%">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="Ngay" HeaderText="Ngày" 
                ReadOnly="True" SortExpression="Ngay" DataFormatString="{0:d}" />
            <asp:BoundField DataField="GiaMua" HeaderText="Giá mua (VND)" 
                SortExpression="GiaMua" DataFormatString="{0:###,##0}" />
            <asp:BoundField DataField="GiaBan" HeaderText="Giá bán (VND)" 
                SortExpression="GiaBan" DataFormatString="{0:###,##0}" />
        </Columns>
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" InsertMethod="InsertVangSJC" 
        SelectMethod="GetVangSJCData" 
        TypeName="BieuDoGiaVang.dsGiaVangTableAdapters.VangSJCTableAdapter" 
        UpdateMethod="UpdateVangSJC" DeleteMethod="Delete" 
        OldValuesParameterFormatString="original_{0}">
        <DeleteParameters>
            <asp:Parameter Name="Original_Ngay" Type="DateTime" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="GiaMua" Type="Decimal" />
            <asp:Parameter Name="GiaBan" Type="Decimal" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="GiaMua" Type="Decimal" />
            <asp:Parameter Name="GiaBan" Type="Decimal" />
            <asp:Parameter Name="Original_Ngay" Type="String" />
        </UpdateParameters>
    </asp:ObjectDataSource>
</asp:Content>
